package com.dormitory.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dormitory.R;
import com.dormitory.bean.UserBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by JHF on 2017/10/16.
 */

public class MemberListAdapter extends BaseAdapter {

    private List<UserBean> mUserList;
    private Activity mActivity;

    public MemberListAdapter(Activity activity) {
        super();

        mUserList = new ArrayList<UserBean>();
        for(int i=0;i<20;i++) {
        }
        mActivity = activity;
    }
    public void updateUser(List<UserBean> notiList) {
        mUserList = notiList;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return mUserList.size();
    }

    @Override
    public Object getItem(int position) {
        return mUserList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        if(convertView != null) {
            view = convertView;
        }
        else {
            view = View.inflate(mActivity, R.layout.memberlist_member, null);
        }
        UserBean userBean = mUserList.get(position);
        ((TextView)view.findViewById(R.id.text_member)).setText(userBean.getName());
        return view;
    }

}
